/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package nite.gestures;

import com.primesense.NITE.PushDetector;
import com.primesense.NITE.ValueEventArgs;
import com.primesense.NITE.VelocityAngleEventArgs;
import java.util.logging.Level;
import java.util.logging.Logger;
import org.OpenNI.GeneralException;
import org.OpenNI.IObservable;
import org.OpenNI.IObserver;

/**
 *
 * @author xvanek9
 */
public class PushGesture extends AbstractGesture {
    
        PrimaryPointUpdateObserver obs;

    public PrimaryPointUpdateObserver getObs() {
        return obs;
    }

    public void setObs(PrimaryPointUpdateObserver obs) {
        this.obs = obs;
    }
    
    public PushDetector init(){
        PushDetector pd = null;
        try {
            pd = new PushDetector();
            pd.getPushEvent().addObserver(new PushObserver());
            pd.getStabilizedEvent().addObserver(new StabilizedObserver());
            obs = new PrimaryPointUpdateObserver();
            pd.getPrimaryPointUpdateEvent().addObserver(obs);
        } catch (GeneralException ex) {
            Logger.getLogger(PushGesture.class.getName()).log(Level.SEVERE, null, ex);
        }
        return pd;
    }
    
        private class PushObserver implements IObserver <VelocityAngleEventArgs>{

        @Override
        public void update(IObservable<VelocityAngleEventArgs> io, VelocityAngleEventArgs args) {
            System.out.println("Pushed, velocity: " + args.getVelocity() + ", angle: " + args.getAngle());
        }
    }
        
        private class StabilizedObserver implements IObserver <ValueEventArgs>{

        @Override
        public void update(IObservable<ValueEventArgs> io, ValueEventArgs args) {
            System.out.println("Stabilized value: " + args.getValue());
        }
        
        }
    
}
